package com.itheima.listener;

import com.itheima.domain.mongo.Movement;
import com.itheima.domain.mongo.MovementScore;
import com.itheima.service.mongo.MovementService;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

@Component
public class MovementScoreListener {

    @Autowired
    private MongoTemplate mongoTemplate;
    //目的: 读取MQ的消息  保存到mongo中
    @RabbitListener(queuesToDeclare = @Queue("tanhua.recommend.movement"))
    public void readMQ(MovementScore movementScore){
        System.out.println("开始保存用户的得分状态");
        mongoTemplate.save(movementScore);
    }
}
